// proxy-server.js

const express = require("express");
const axios = require("axios");

const app = express();
const PORT = process.env.PORT || 3000;

// 定义API代理的路由
app.get("/api/*", async (req, res) => {
  try {
    const apiUrl = req.url.replace("/api/", "http://api.jutuike.com");
    const response = await axios.get(apiUrl);
    res.json(response.data);
  } catch (error) {
    res.status(error.response.status).json(error.response.data);
  }
});

// 启动服务器
app.listen(PORT, () => {
  console.log(`代理服务器正在监听端口 ${PORT}`);
});
